kandukondein
April 22nd, 2003, 12:13 PM
How to know whether a user already exists..I have a code which runs for the first time when there are no users by that name,
ssecond time it fails. i want to stop it run the second time so i have to know whether the user already exists,
How to do that..
Expecting ur replies
Regards
Kandukondein
set cont = GetObject("LDAP://" & strContainerDN )
if Err.Number <> 0 then
Response.Write "GetObject Users Container Error = " & Hex(Err.Number) & " (Source: " & Err.Source & ")"
end if
Err.Clear
' create the user account
Set user = cont.Create("user", "cn=" & strCurrentUserEmail)
Response.Write ("The name of the user is " & user.Name)
' WARNING!!!
' Before going live with a site based on this sample code,
' the following must be changed so that a random password
' is assigned to each account. A recommended way to do this
' is to use the CAPICOM Utilities.GetRandom function.
'
if Err.Number <> 0 then
Response.Write "Create User Error = " & Hex(Err.Number) & " (Source: " & Err.Source & ")"
end if
Response.Write ("The error number is " & Err.Number )
user.put "samAccountName", strPUID
strFullAccountName = strPUID & "@" & strDomainName
user.put "altSecurityIdentities", "Kerberos:" & strFullAccountName
' set the UPN of the user to equal the PP e-mail address
Response.Write (Err.Number)
user.put "userPrincipalName", strCurrentUserEmail
user.put "givenName", strFirstName
user.put "sn", strLastName
Response.Write (Err.Number)
user.put "userPassword", "sav123"
' call user.SetPassword("sav123")
' write the property cache
user.SetInfo
' refresh the property cache
user.GetInfo
' clear the account disabled flag and set neccessary flags
'
Response.Write(Err.Number)
flags = user.get("userAccountControl")
Response.Write(Err.Number)
flags = flags OR &H00010000
flags = flags AND &HFFFFFFFD
user.put "userAccountControl", flags
user.SetInfo
ssecond time it fails. i want to stop it run the second time so i have to know whether the user already exists,
How to do that..
Expecting ur replies
Regards
Kandukondein
set cont = GetObject("LDAP://" & strContainerDN )
if Err.Number <> 0 then
Response.Write "GetObject Users Container Error = " & Hex(Err.Number) & " (Source: " & Err.Source & ")"
end if
Err.Clear
' create the user account
Set user = cont.Create("user", "cn=" & strCurrentUserEmail)
Response.Write ("The name of the user is " & user.Name)
' WARNING!!!
' Before going live with a site based on this sample code,
' the following must be changed so that a random password
' is assigned to each account. A recommended way to do this
' is to use the CAPICOM Utilities.GetRandom function.
'
if Err.Number <> 0 then
Response.Write "Create User Error = " & Hex(Err.Number) & " (Source: " & Err.Source & ")"
end if
Response.Write ("The error number is " & Err.Number )
user.put "samAccountName", strPUID
strFullAccountName = strPUID & "@" & strDomainName
user.put "altSecurityIdentities", "Kerberos:" & strFullAccountName
' set the UPN of the user to equal the PP e-mail address
Response.Write (Err.Number)
user.put "userPrincipalName", strCurrentUserEmail
user.put "givenName", strFirstName
user.put "sn", strLastName
Response.Write (Err.Number)
user.put "userPassword", "sav123"
' call user.SetPassword("sav123")
' write the property cache
user.SetInfo
' refresh the property cache
user.GetInfo
' clear the account disabled flag and set neccessary flags
'
Response.Write(Err.Number)
flags = user.get("userAccountControl")
Response.Write(Err.Number)
flags = flags OR &H00010000
flags = flags AND &HFFFFFFFD
user.put "userAccountControl", flags
user.SetInfo