Click here to Skip to main content
15,901,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello people,

I found error as -
Directory service com exception was caught
The specified directory service attribute or value does not exist. (Exception from HRESULT: 0x8007200A)

Here my code -
C#
DirectoryEntry ent = new DirectoryEntry("LDAP://serverip", "username", "password", AuthenticationTypes.Secure);
ent.Children.Add("cn='" + TxtGroupName.Text + "'", "group");
ent.Properties["saMAccountName"].Add(TxtGroupName.Text);
ent.Properties["groupScope"].Add("0x02");
ent.Properties["groupType"].Add("0x80000000");
ent.CommitChanges();
MessageBox.Show("creted");

Please give me solution.
Posted
Updated 14-Nov-11 20:27pm
v4

 
Share this answer
 
v2
Comments
Nivas Maran 14-Nov-11 8:20am    
thatraja i tried but still having same error
thatraja 14-Nov-11 8:24am    
Check my updated answer
I open my AD scheme and not found attribute groupScope. Are you sure, that this one exists in your scheme?
 
Share this answer
 
Comments
Nivas Maran 14-Nov-11 8:38am    
group type and group scope is needed in creating group in "server" right.. i want to create this group in server
Nickos_me 14-Nov-11 8:58am    
No, I ask you not about this. Open ADSI Edit. Create some group. Right-click this group and select "properties". You can see property saMAccountName, groupType. But do you see groupScope?
Nickos_me 14-Nov-11 9:20am    
Okay, I understand. You want to create group with code like that:
DirectoryEntry ent = new DirectoryEntry("LDAP://serverip", "username", "password", AuthenticationTypes.Secure);
ent.Children.Add("cn='" + TxtGroupName.Text + "'", "group");
ent.Properties["saMAccountName"].Add(TxtGroupName.Text);
ent.Properties["groupType"].Add("0x80000002");
ent.CommitChanges();
MessageBox.Show("creted");

After that, look that you have :)

Try it - as I understand, property groupType is result of or operation between 0x80000000 and 0x02. Try it please :)
Nivas Maran 15-Nov-11 1:04am    
nickos_me

i tried this above code too... the same error appearing.... pls fix it... it will make trouble for past two days...
Nickos_me 15-Nov-11 5:50am    
Hm..I remember. Try this one:

ent.Properties["saMAccountName"].Value=TxtGroupName.Text; ent.Properties["groupType"].Value="0x80000002"; (or, maybe, ent.Properties["groupType"].Value=0x80000002) instead of Properties["..."].Add
DirectoryEntry ent = new DirectoryEntry("LDAP://serverip", "username", "password", AuthenticationTypes.Secure);
ent.Children.Add("cn='" + TxtGroupName.Text + "'", "group");
ent.Properties["saMAccountName"].Add(TxtGroupName.Text);
ent.Properties["groupType"].Add("0x80000002");
ent.CommitChanges();
MessageBox.Show("creted");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900